package test.redis;

import redis.clients.jedis.JedisSentinelPool;

import java.util.HashSet;
import java.util.Set;

/**
 * @Author: sunshuo
 * @Date: 2019/8/9/009 16:34
 * @Version: 1.0
 */
public class RedisSentinelUtil extends RedisUtil {

    public RedisSentinelUtil() {
        String masterName = RedisProperties.getString("redis.master.name", "mymaster");
        Set<String> sentinels = new HashSet<>();
        sentinels.add(RedisProperties.getString("redis.sentinel1.host", "192.168.75.224") + ":" +
                RedisProperties.getString("redis.sentinel1.port", "26379"));
        sentinels.add(RedisProperties.getString("redis.sentinel2.host", "192.168.75.225") + ":" +
                RedisProperties.getString("redis.sentinel1.port", "26379"));
        sentinels.add(RedisProperties.getString("redis.sentinel3.host", "192.168.75.226") + ":" +
                RedisProperties.getString("redis.sentinel1.port", "26379"));

        jedisPool = new JedisSentinelPool(masterName, sentinels, RedisConfig.poolConfig, RedisConfig.timeout,
                RedisConfig.password);
    }
}
